package com.beilang.hotline.email.page;

import java.util.Date;

import com.beilang.base.core.page.BasePage;
import com.beilang.base.util.DateUtil;
import com.beilang.hotline.email.manager.EmailServerMgr;
import com.beilang.hotline.email.model.EmailServerModel;
import com.beilang.hotline.user.model.UserModel;

public class EmailPage extends BasePage {

	private EmailServerMgr emailServerMgr;

	public void setEmailServerMgr(EmailServerMgr emailServerMgr) {
		this.emailServerMgr = emailServerMgr;
	}

	public EmailServerModel getEmailServer() {
		return emailServerMgr.getEmailServer();
	}

	public EmailServerModel updateEmailServer(EmailServerModel emailServerModel) {
		UserModel user=this.getLoginUser();
		if(emailServerModel.getEmailId()==0){
			emailServerModel.setCreateId(user.getUserId());
			emailServerModel.setUpdateId(user.getUserId());
			Date date=DateUtil.getDate();
			emailServerModel.setCreateTime(date);
			emailServerModel.setUpdateTime(date);
		}else{
			emailServerModel.setUpdateId(user.getUserId());
			emailServerModel.setUpdateTime(DateUtil.getDate());
		}
		emailServerModel= emailServerMgr.saveEmailServer(emailServerModel);
		return emailServerModel;
	}

}
